class SessionsController < ApplicationController
  layout "joke"
  skip_before_filter :login_required,:only => [:new,:new_user,:create_user,:create]
  # render new.rhtml
  def new
  end

  def create
    user = User.authenticate(params[:username], params[:password])
    if user
      session[:user_keys] = user.login
      redirect_to "/"
      flash[:notice] = "Logged in successfully"
    else
      render :action => 'new'
    end
  end

  def destroy
    session[:user_keys] = nil
    flash[:notice] = "You have been logged out."
    redirect_back_or_default('/')
  end

end

